From b031b7b131008e3a13e8c146c0c7c3bee70e4df8 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Tue, 2 Aug 2005 15:42:03 +0000 Subject: [PATCH] Support for templates in , in templates, in templates in , and other such funky things --- includes/Parser.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/includes/Parser.php b/includes/Parser.php index ff743b03bf..9d1ca27b00 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -111,6 +111,7 @@ class Parser // in this path. Used for loop detection. var $mIWTransData = array(); + var $mAssocArgs = array(); /**#@-*/ @@ -469,6 +470,10 @@ class Parser * @access private */ function unstrip( $text, &$state ) { + if ( !is_array( $state ) ) { + return $text; + } + # Must expand in reverse order, otherwise nested tags will be corrupted $contentDict = end( $state ); for ( $contentDict = end( $state ); $contentDict !== false; $contentDict = prev( $state ) ) { @@ -488,6 +493,10 @@ class Parser * @access private */ function unstripNoWiki( $text, &$state ) { + if ( !is_array( $state ) ) { + return $text; + } + # Must expand in reverse order, otherwise nested tags will be corrupted for ( $content = end($state['nowiki']); $content !== false; $content = prev( $state['nowiki'] ) ) { $text = str_replace( key( $state['nowiki'] ), $content, $text ); @@ -2257,12 +2266,12 @@ class Parser $text = wfEscapeWikiText( $text ); } elseif ( ($this->mOutputType == OT_HTML || $this->mOutputType == OT_WIKI) && $found && !$noparse) { # Clean up argument array - $assocArgs = array(); + $this->mAssocArgs = array(); $index = 1; foreach( $args as $arg ) { $eqpos = strpos( $arg, '=' ); if ( $eqpos === false ) { - $assocArgs[$index++] = $arg; + $this->mAssocArgs[$index++] = $arg; } else { $name = trim( substr( $arg, 0, $eqpos ) ); $value = trim( substr( $arg, $eqpos+1 ) ); @@ -2270,7 +2279,7 @@ class Parser $value = ''; } if ( $name !== false ) { - $assocArgs[$name] = $value; + $this->mAssocArgs[$name] = $value; } } } @@ -2280,9 +2289,9 @@ class Parser if( $this->mOutputType == OT_HTML ) { $text = $this->strip( $text, $this->mStripState ); - $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'replaceVariables' ), $assocArgs ); + $text = Sanitizer::removeHTMLtags( $text, array( &$this, 'replaceVariables' ), $this->mAssocArgs ); } - $text = $this->replaceVariables( $text, $assocArgs ); + $text = $this->replaceVariables( $text, $this->mAssocArgs ); # Resume the link cache and register the inclusion as a link if ( $this->mOutputType == OT_HTML && !is_null( $title ) ) { -- 2.20.1